import os

# 扩展名到语言
exts = {
    "py": "python",
    "pyw": "python",
    "js": "javascript",
    "java": "java",
    "js": "javascript",
    "c": "c",
    "h": "c",
    "cpp": "cpp",
    "c++": "cpp",
    "cxx": "cpp",
    "hpp": "cpp",
    "hxx": "cpp",
    "cc": "cpp",
    "m": "c",
    "mm": "cpp",
    "rs": "rust",
    "go": "go",
    "html": "html",
    "css": "css",
    "json": "json",
    "md": "markdown",
    "markdown": "markdown",
    "txt": "text",
    "yaml": "yaml",
    "toml": "toml",
    "yml": "yaml",
    "xml": "xml",
    "ini": "ini",
    "conf": "ini",
    "cfg": "ini",
    "log": "systemverilog",
    "sh": "shell",
    "bat": "bat",
    "cmd": "bat",
    "sql": "sql",
    "php": "php",
    "rb": "ruby",
    "swift": "swift",
    "kt": "kotlin",
    "dart": "dart",
    "ts": "typescript",
    "tsx": "typescript",
    "jsx": "javascript",
    "vue": "vue",
    "cs": "csharp",
    "dockerfile": "dockerfile",
    "Dockerfile": "dockerfile",
    "hbs": "handlebars",
    "ruby": "ruby",
    "scss": "scss",
    "less": "less",
    "tcl": "tcl",
    "lua": "lua",
    "gql": "graphql",
    "graphql": "graphql",
    "ps": "powershell",
    "ps1": "powershell",
    "ps2": "powershell",
    "redis": "redis",
    "proto": "protobuf",
    "proto3": "protobuf",
    "proto2": "protobuf",
    "rst": "restructuredtext",
    "wsgl": "wsgl",
}


# 获取文件扩展名
def get_ext(filepath: str):
    # 默认为text
    return exts.get(filepath.split(os.sep)[-1].split(".")[-1], "text")
